prevent gdk_init() from segfaulting when invoked with (NULL, NULL); (this
authorTim Janik <timj@gtk.org>
Wed, 10 Jun 1998 07:32:52 +0000 (07:32 +0000)
committerTim Janik <timj@src.gnome.org>
Wed, 10 Jun 1998 07:32:52 +0000 (07:32 +0000)
Wed Jun 10 06:25:17 1998  Tim Janik  <timj@gtk.org>

        * gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
        invoked with (NULL, NULL); (this worked sometime ago).

        * gtk/gtktypeutils.h:
        * gtk/gtktypeutils.c: enum and flags type creation can now be done
        through gtk_type_register_enum() and gtk_type_register_flags(),
        which allow to specify the enum value arrays directly.
        the NULL terminated value arrays can be retrived through
        gtk_type_enum_get_values() and gtk_type_flags_get_values();
        (gtk_type_children_types): new function to query derived types.

12 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdk.c
gdk/x11/gdkmain-x11.c
gtk/gtkmain.c
gtk/gtktypeutils.c
gtk/gtktypeutils.h

index ccfee9494077306429cc11dd543b62b75d3b0fbe..140772a93dbe04f04a60bb1106e9f340fb79f4fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,15 @@
 Wed Jun 10 06:25:17 1998  Tim Janik  <timj@gtk.org>
 
+       * gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
+       invoked with (NULL, NULL); (this worked sometime ago).
+
        * gtk/gtktypeutils.h: 
        * gtk/gtktypeutils.c: enum and flags type creation can now be done
        through gtk_type_register_enum() and gtk_type_register_flags(),
        which allow to specify the enum value arrays directly.
        the NULL terminated value arrays can be retrived through
        gtk_type_enum_get_values() and gtk_type_flags_get_values();
+       (gtk_type_children_types): new function to query derived types.
 
 1998-06-09  Raja R Harinath  <harinath@cs.umn.edu>
 
index ccfee9494077306429cc11dd543b62b75d3b0fbe..140772a93dbe04f04a60bb1106e9f340fb79f4fe 100644 (file)
@@ -1,11 +1,15 @@
 Wed Jun 10 06:25:17 1998  Tim Janik  <timj@gtk.org>
 
+       * gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
+       invoked with (NULL, NULL); (this worked sometime ago).
+
        * gtk/gtktypeutils.h: 
        * gtk/gtktypeutils.c: enum and flags type creation can now be done
        through gtk_type_register_enum() and gtk_type_register_flags(),
        which allow to specify the enum value arrays directly.
        the NULL terminated value arrays can be retrived through
        gtk_type_enum_get_values() and gtk_type_flags_get_values();
+       (gtk_type_children_types): new function to query derived types.
 
 1998-06-09  Raja R Harinath  <harinath@cs.umn.edu>
 
index ccfee9494077306429cc11dd543b62b75d3b0fbe..140772a93dbe04f04a60bb1106e9f340fb79f4fe 100644 (file)
@@ -1,11 +1,15 @@
 Wed Jun 10 06:25:17 1998  Tim Janik  <timj@gtk.org>
 
+       * gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
+       invoked with (NULL, NULL); (this worked sometime ago).
+
        * gtk/gtktypeutils.h: 
        * gtk/gtktypeutils.c: enum and flags type creation can now be done
        through gtk_type_register_enum() and gtk_type_register_flags(),
        which allow to specify the enum value arrays directly.
        the NULL terminated value arrays can be retrived through
        gtk_type_enum_get_values() and gtk_type_flags_get_values();
+       (gtk_type_children_types): new function to query derived types.
 
 1998-06-09  Raja R Harinath  <harinath@cs.umn.edu>
 
index ccfee9494077306429cc11dd543b62b75d3b0fbe..140772a93dbe04f04a60bb1106e9f340fb79f4fe 100644 (file)
@@ -1,11 +1,15 @@
 Wed Jun 10 06:25:17 1998  Tim Janik  <timj@gtk.org>
 
+       * gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
+       invoked with (NULL, NULL); (this worked sometime ago).
+
        * gtk/gtktypeutils.h: 
        * gtk/gtktypeutils.c: enum and flags type creation can now be done
        through gtk_type_register_enum() and gtk_type_register_flags(),
        which allow to specify the enum value arrays directly.
        the NULL terminated value arrays can be retrived through
        gtk_type_enum_get_values() and gtk_type_flags_get_values();
+       (gtk_type_children_types): new function to query derived types.
 
 1998-06-09  Raja R Harinath  <harinath@cs.umn.edu>
 
index ccfee9494077306429cc11dd543b62b75d3b0fbe..140772a93dbe04f04a60bb1106e9f340fb79f4fe 100644 (file)
@@ -1,11 +1,15 @@
 Wed Jun 10 06:25:17 1998  Tim Janik  <timj@gtk.org>
 
+       * gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
+       invoked with (NULL, NULL); (this worked sometime ago).
+
        * gtk/gtktypeutils.h: 
        * gtk/gtktypeutils.c: enum and flags type creation can now be done
        through gtk_type_register_enum() and gtk_type_register_flags(),
        which allow to specify the enum value arrays directly.
        the NULL terminated value arrays can be retrived through
        gtk_type_enum_get_values() and gtk_type_flags_get_values();
+       (gtk_type_children_types): new function to query derived types.
 
 1998-06-09  Raja R Harinath  <harinath@cs.umn.edu>
 
index ccfee9494077306429cc11dd543b62b75d3b0fbe..140772a93dbe04f04a60bb1106e9f340fb79f4fe 100644 (file)
@@ -1,11 +1,15 @@
 Wed Jun 10 06:25:17 1998  Tim Janik  <timj@gtk.org>
 
+       * gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
+       invoked with (NULL, NULL); (this worked sometime ago).
+
        * gtk/gtktypeutils.h: 
        * gtk/gtktypeutils.c: enum and flags type creation can now be done
        through gtk_type_register_enum() and gtk_type_register_flags(),
        which allow to specify the enum value arrays directly.
        the NULL terminated value arrays can be retrived through
        gtk_type_enum_get_values() and gtk_type_flags_get_values();
+       (gtk_type_children_types): new function to query derived types.
 
 1998-06-09  Raja R Harinath  <harinath@cs.umn.edu>
 
index ccfee9494077306429cc11dd543b62b75d3b0fbe..140772a93dbe04f04a60bb1106e9f340fb79f4fe 100644 (file)
@@ -1,11 +1,15 @@
 Wed Jun 10 06:25:17 1998  Tim Janik  <timj@gtk.org>
 
+       * gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
+       invoked with (NULL, NULL); (this worked sometime ago).
+
        * gtk/gtktypeutils.h: 
        * gtk/gtktypeutils.c: enum and flags type creation can now be done
        through gtk_type_register_enum() and gtk_type_register_flags(),
        which allow to specify the enum value arrays directly.
        the NULL terminated value arrays can be retrived through
        gtk_type_enum_get_values() and gtk_type_flags_get_values();
+       (gtk_type_children_types): new function to query derived types.
 
 1998-06-09  Raja R Harinath  <harinath@cs.umn.edu>
 
index 6b5f4021f51bac2e1979652f5845158da60dfebb..ab2604ed25efa270cf6943d8de87b2029dfb271b 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -160,7 +160,7 @@ static void   gdk_ic_cleanup                (void);
 
 /* Private variable declarations
  */
-static int initialized = 0;                         /* 1 if the library is initialized,
+static int gdk_initialized = 0;                     /* 1 if the library is initialized,
                                                     * 0 otherwise.
                                                     */
 static int connection_number = 0;                   /* The file descriptor number of our
@@ -268,13 +268,21 @@ gdk_init (int    *argc,
   gint synchronize;
   gint i, j, k;
   XClassHint *class_hint;
-  gint argc_orig = *argc;
-  gchar **argv_orig;
+  gchar **argv_orig = NULL;
+  gint argc_orig = 0;
 
-  argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
-  for (i = 0; i < argc_orig; i++)
-    argv_orig[i] = g_strdup ((*argv)[i]);
-  argv_orig[argc_orig] = NULL;
+  if (gdk_initialized)
+    return;
+
+  if (argc && argv)
+    {
+      argc_orig = *argc;
+      
+      argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
+      for (i = 0; i < argc_orig; i++)
+       argv_orig[i] = g_strdup ((*argv)[i]);
+      argv_orig[argc_orig] = NULL;
+    }
 
   X_GETTIMEOFDAY (&start);
 
@@ -316,8 +324,6 @@ gdk_init (int    *argc,
            gdk_progname = g_strdup (d + 1);
          else
            gdk_progname = g_strdup ((*argv)[0]);
-         GDK_NOTE (MISC,
-                   g_print ("Gdk: progname: \"%s\"\n", gdk_progname));
        }
 
       for (i = 1; i < *argc;)
@@ -484,6 +490,8 @@ gdk_init (int    *argc,
       gdk_progname = "<unknown>";
     }
 
+  GDK_NOTE (MISC, g_print ("Gdk: progname: \"%s\"\n", gdk_progname));
+
   gdk_display = XOpenDisplay (gdk_display_name);
   if (!gdk_display)
     {
@@ -579,7 +587,7 @@ gdk_init (int    *argc,
   gdk_im_open (NULL, NULL, NULL);
 #endif
 
-  initialized = 1;
+  gdk_initialized = 1;
 }
 
 /*
@@ -3159,10 +3167,11 @@ gdk_exit_func (void)
   /* This is to avoid an infinite loop if a program segfaults in
      an atexit() handler (and yes, it does happen, especially if a program
      has trounced over memory too badly for even g_print to work) */
-  if(in_gdk_exit_func == TRUE) return;
+  if (in_gdk_exit_func == TRUE)
+    return;
   in_gdk_exit_func = TRUE;
 
-  if (initialized)
+  if (gdk_initialized)
     {
 #ifdef USE_XIM
       /* cleanup IC */
@@ -3175,7 +3184,7 @@ gdk_exit_func (void)
       gdk_key_repeat_restore ();
 
       XCloseDisplay (gdk_display);
-      initialized = 0;
+      gdk_initialized = 0;
     }
 }
 
index 6b5f4021f51bac2e1979652f5845158da60dfebb..ab2604ed25efa270cf6943d8de87b2029dfb271b 100644 (file)
@@ -160,7 +160,7 @@ static void   gdk_ic_cleanup                (void);
 
 /* Private variable declarations
  */
-static int initialized = 0;                         /* 1 if the library is initialized,
+static int gdk_initialized = 0;                     /* 1 if the library is initialized,
                                                     * 0 otherwise.
                                                     */
 static int connection_number = 0;                   /* The file descriptor number of our
@@ -268,13 +268,21 @@ gdk_init (int    *argc,
   gint synchronize;
   gint i, j, k;
   XClassHint *class_hint;
-  gint argc_orig = *argc;
-  gchar **argv_orig;
+  gchar **argv_orig = NULL;
+  gint argc_orig = 0;
 
-  argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
-  for (i = 0; i < argc_orig; i++)
-    argv_orig[i] = g_strdup ((*argv)[i]);
-  argv_orig[argc_orig] = NULL;
+  if (gdk_initialized)
+    return;
+
+  if (argc && argv)
+    {
+      argc_orig = *argc;
+      
+      argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
+      for (i = 0; i < argc_orig; i++)
+       argv_orig[i] = g_strdup ((*argv)[i]);
+      argv_orig[argc_orig] = NULL;
+    }
 
   X_GETTIMEOFDAY (&start);
 
@@ -316,8 +324,6 @@ gdk_init (int    *argc,
            gdk_progname = g_strdup (d + 1);
          else
            gdk_progname = g_strdup ((*argv)[0]);
-         GDK_NOTE (MISC,
-                   g_print ("Gdk: progname: \"%s\"\n", gdk_progname));
        }
 
       for (i = 1; i < *argc;)
@@ -484,6 +490,8 @@ gdk_init (int    *argc,
       gdk_progname = "<unknown>";
     }
 
+  GDK_NOTE (MISC, g_print ("Gdk: progname: \"%s\"\n", gdk_progname));
+
   gdk_display = XOpenDisplay (gdk_display_name);
   if (!gdk_display)
     {
@@ -579,7 +587,7 @@ gdk_init (int    *argc,
   gdk_im_open (NULL, NULL, NULL);
 #endif
 
-  initialized = 1;
+  gdk_initialized = 1;
 }
 
 /*
@@ -3159,10 +3167,11 @@ gdk_exit_func (void)
   /* This is to avoid an infinite loop if a program segfaults in
      an atexit() handler (and yes, it does happen, especially if a program
      has trounced over memory too badly for even g_print to work) */
-  if(in_gdk_exit_func == TRUE) return;
+  if (in_gdk_exit_func == TRUE)
+    return;
   in_gdk_exit_func = TRUE;
 
-  if (initialized)
+  if (gdk_initialized)
     {
 #ifdef USE_XIM
       /* cleanup IC */
@@ -3175,7 +3184,7 @@ gdk_exit_func (void)
       gdk_key_repeat_restore ();
 
       XCloseDisplay (gdk_display);
-      initialized = 0;
+      gdk_initialized = 0;
     }
 }
 
index 02fb22ceb23e004c38e9115a6821f0ffe43cb08f..802ebce6af4650c74991d00aef7ffa8918ca6ff5 100644 (file)
@@ -140,7 +140,7 @@ const guint gtk_micro_version = GTK_MICRO_VERSION;
 
 static gboolean iteration_done = FALSE;
 static guint main_level = 0;
-static gint initialized = FALSE;
+static gint gtk_initialized = FALSE;
 static GdkEvent *next_event = NULL;
 static GList *current_events = NULL;
 
@@ -231,12 +231,10 @@ void
 gtk_init (int   *argc,
          char ***argv)
 {
-  static gboolean gtk_initialized = FALSE;
   gchar *current_locale;
 
   if (gtk_initialized)
     return;
-  gtk_initialized = TRUE;
 
   if (0)
     {
@@ -331,7 +329,7 @@ gtk_init (int        *argc,
 
   /* Check if there is a good chance the mb functions will handle things
    * correctly - set if either mblen("\xc0", MB_CUR_MAX) == 1 in the
-   * C locale, or were using X's mb functions. (-DX_LOCALE && locale != C)
+   * C locale, or we're using X's mb functions. (-DX_LOCALE && locale != C)
    */
 
   current_locale = g_strdup (setlocale (LC_CTYPE, NULL));
@@ -371,7 +369,7 @@ gtk_init (int        *argc,
   
   /* Set the 'initialized' flag.
    */
-  initialized = TRUE;
+  gtk_initialized = TRUE;
 }
 
 void
@@ -1354,9 +1352,9 @@ gtk_get_event_widget (GdkEvent *event)
 static void
 gtk_exit_func (void)
 {
-  if (initialized)
+  if (gtk_initialized)
     {
-      initialized = FALSE;
+      gtk_initialized = FALSE;
       gtk_preview_uninit ();
     }
 }
index 578744ce2441158207c9eef1f66aaa5a8a4e7281..02dd046913e7682d6b46c8ef0bc343d2c66ef31f 100644 (file)
@@ -368,11 +368,23 @@ gtk_type_free (GtkType      type,
     g_free (mem);
 }
 
+GList*
+gtk_type_children_types (GtkType type)
+{
+  GtkTypeNode *node;
+
+  LOOKUP_TYPE_NODE (node, type);
+  if (node)
+    return node->children_types;
+
+  return NULL;
+}
+
 void
 gtk_type_describe_heritage (GtkType type)
 {
   GtkTypeNode *node;
-  gint first;
+  gboolean first;
 
   LOOKUP_TYPE_NODE (node, type);
   first = TRUE;
@@ -395,8 +407,8 @@ gtk_type_describe_heritage (GtkType type)
 }
 
 void
-gtk_type_describe_tree (GtkType type,
-                       gint  show_size)
+gtk_type_describe_tree (GtkType  type,
+                       gboolean show_size)
 {
   GtkTypeNode *node;
   
index 720fc9ffa7fd397bafe3cd0a688716fc369d71e3..3f390c3f4365355e7565f3c01338ed4d442f9590 100644 (file)
@@ -197,6 +197,7 @@ GtkType             gtk_type_from_name              (const gchar    *name);
 GtkType                gtk_type_parent                 (GtkType         type);
 gpointer       gtk_type_class                  (GtkType         type);
 gpointer       gtk_type_parent_class           (GtkType         type);
+GList*         gtk_type_children_types         (GtkType         type);
 gpointer       gtk_type_new                    (GtkType         type);
 void           gtk_type_free                   (GtkType         type,
                                                 gpointer        mem);